<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>席位交易量统计表</title>
    <!--导入layui包-->
    <link rel="stylesheet" href="../layui/css/layui.css"/>
    <script src="../jQuery/jquery-1.11.2.js"></script>
    <script src="../layui/layui.js"></script>
    <link rel="stylesheet" type="text/css" href="/css/font.css">
    <style>::-webkit-scrollbar{display: none;}</style>
</head>
<body>
    <!--数据表格-->
    <table class="layui-hide" id="DayStatement" lay-filter="secStockList"></table>

    <script type="text/html" id="day_search">
        <!--多条件查询层-->
        <div class="layui-inline">
            券商席位:
            <div class="layui-input-inline">
                <select name="seatId" id="seatId"></select>
            </div>
            <button id="search" class="layui-btn  layui-btn-primary layui-bg-gray" lay-submit data-type="reload" lay-filter="provinceSearch">
                <i class="layui-icon">&#xe615;</i>
            </button>
        </div>
        <!--多条件查询结束-->
        <div class="layui-btn-container layui-input-inline" style="margin-left: 1000px;top: -40px;">
            <button class="layui-btn layui-btn-danger" lay-event="batchDel">
                <i class="layui-icon">&#xe640;</i>批量删除
            </button>
        </div>
    </script>

    <!-- 行中操作按钮[仅对本行操作] -->
    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-danger layui-btn-xs layui-icon layui-icon-delete" lay-event="delete">删除</a>
    </script>

    <!--脚本代码-->
    <script type="text/javascript">
        layui.use(['table','layer','form','laypage','util','jquery'],function () {
            //导入模块并得到模块对象
            var table = layui.table,//表格对象
                layer = layui.layer,//弹层对象
                form = layui.form,//表单对象
                laypage = layui.laypage,//分页组件
                $ = layui.jquery,//jquery对象
                util = layui.util;//工具对象
            var tables;
            var vals="";
            var varseName="<option value=''>--请选择--</option>";
            //开关用于避免重复添加搜索框
            var tufa=false;
            //开关用于避免重复执行
            var tafa=true;
            var two;
            //渲染表格对象
            tables=table.render({
                //id:"houseReload",//为多条件搜索重新加载使用
                elem: "#DayStatement",//表格对象
                url: "../json/DayStatement.json",//后台服务路径
                method: "post",//提交方式
                height:740,
                toolbar: "#day_search",//表格上方普通工具栏
                //一页显示5条数据
                limit: 15,
                cols: [
                    [
                        {checkbox: true},//开启多选框
                        {field:"seatId",title:"券商席位",align:"center"},
                        {field:"inStock",title:"买入股票（支）",align:"center"},
                        {field:"outStock",title:"卖出股票（支）",align:"center"},
                        {field:"inBond",title:"买入债券（支）",align:"center"},
                        {field:"outBond",title:"卖出债券（支）",align:"center"},
                        {field:"inMoney",title:"回购金额（元）",align:"center"},
                        {field:"totalNum",title:"金额合计（元）",align:"center"},
                        {field:"rate",title:"交易量比例",align:"center"},
                        {fixed:"right",title:"操作",width:160,align:"center",toolbar:"#barDemo"}
                    ]
                ],parseData:function (res) {
                    var datasTwo = new Array();
                    //证券
                    two = res.securi;
                    var twoStr = "<option value=''>--请选择--</option>";
                    for (var i = 0; i < two.length; i++) {
                        twoStr += "<option value='" + two[i].seName + "'>" + two[i].seName + "</option>";
                    }
                    $("#seName").html(twoStr);
                    for (var i = 0; i < res.data.length; i++) {
                        if (vals == "") {
                            datasTwo.push(res.data[i]);
                        } else if (res.data[i].seatId == vals) {
                            datasTwo.push(res.data[i]);
                        }
                    }
                    return {
                        "code": res.code,
                        "msg": res.msg,
                        "count": datasTwo.length,
                        "data": datasTwo
                    }
                },
                page: true,
                //一页选择显示5或10条数据
                limits: [5, 10,20,30,50]
            });
            //表格头部工具栏事件代码，根据lay-event属性值判断执行相应的代码
            table.on('toolbar(secStockList)',function (obj) {
                var checkStatus = table.checkStatus(obj.config.id);
                //判断事件event值
                switch (obj.event) {
                    //批量删除操作：删除选定的多行数据
                    case "batchDel":
                        //获得选中的表格行
                        var data = checkStatus.data;
                        //判断是否大于0行
                        if (data.length > 0) {
                            layer.confirm('请确认是否真的删除?', function (index) {
                                //获取所有选择的id
                                var empNoStr = "";

                                for (var i = 0; i < data.length; i++) {
                                    empNoStr = empNoStr + data[i].MoneyId + ",";//累加字符
                                }
                                layer.close(index);
                                //使用ajax删除选中的
                                $.ajax({
                                    type: "",//提交方式为post
                                    url: "",//后台Servlet路径
                                    data: "",
                                    success: function (msg) {
                                        layer.msg('删除成功');
                                        //重新加载表格数据
                                        table.reload('DayStatement');
                                    }
                                });
                            });
                        } else {
                            //没有选择数据行
                            layer.msg('你至少选一行！');
                        }
                        break;
                }
            });
            table.on("tool(secStockList)",function (obj) {
                //得到表格行数据
                var data = obj.data;
                if (obj.event == "delete") {//判断是否为行删除操作
                    layer.confirm("真的科目编号为" + data.ObjId + "这行数据吗?", function (index) {
                        //执行表格中删除操作
                        obj.del();
                        layer.close(index);
                        $.ajax({
                            type: "",
                            url: "",//后台Servlet路径
                            data: "",
                            success: function (msg) {
                                //重新加载表格数据
                                //table.reload('empTable');
                            }
                        });
                    });
                }
            });
            form.on("submit(provinceSearch)",function (data) {
                vals=data.field.seName;
                /* //定义表单数据对象
                 var formData=data.field;
                 //得到表单数据json字符串
                 var json=JSON.stringify(data.field);*/
                //alert(json);
                //重新加载表格对象
                tables.reload("secStockList");
                /*return false;*/
            });
        });
    </script>
</body>
</html>